package net.zhengxinyun.performance.service.examNew;

import net.zhengxinyun.performance.Util.StringUtils;
import net.zhengxinyun.performance.entity.exam.UnSysUsers;
import net.zhengxinyun.performance.entity.exam.UserTypeEntity;
import net.zhengxinyun.performance.filter.exam.UnSysUserFilter;
import net.zhengxinyun.performance.filter.exam.UsersTypeFilter;
import net.zhengxinyun.performance.mapper.examNew.UnSysUsersMapper;
import net.zhengxinyun.performance.mapper.examNew.UserTypeEntityMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UnSysUserServiceImpl implements UnSysUserService {

    @Autowired
    private UnSysUsersMapper mapper;

    @Autowired
    private UserTypeEntityMapper typeMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(UnSysUsers record) {
        return mapper.insert(record);
    }

    @Override
    public int insertSelective(UnSysUsers record) {
        return mapper.insertSelective(record);
    }

    @Override
    public UnSysUsers selectByPrimaryKey(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(UnSysUsers record) {
        return mapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(UnSysUsers record) {
        return mapper.updateByPrimaryKey(record);
    }

    @Override
    public List<UnSysUserFilter> seletListUsers(UnSysUserFilter filter) {

        UnSysUsers record = new UnSysUsers();

        if(StringUtils.isNotBlank(filter.getUserName()))
            record.setUserName(filter.getUserName());

        if(StringUtils.isNotBlank(filter.getUserSex()))
            record.setUserSex (filter.getUserSex());

        if(StringUtils.isNotBlank(filter.getUserType()))
            record.setUserType(filter.getUserType());

        if(StringUtils.isNotBlank(filter.getUserTel()))
            record.setUserTel (filter.getUserTel());



        return mapper.seletListUsers(record);
    }


    @Override
    public int deleteTypeByPrimaryKey(Long id) {
        return typeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertType(UserTypeEntity record) {
        return typeMapper.insert(record);
    }

    @Override
    public int insertTypeSelective(UserTypeEntity record) {
        return typeMapper.insertSelective(record);
    }

    @Override
    public UserTypeEntity selectTypeByPrimaryKey(Long id) {
        return typeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateTypeByPrimaryKeySelective(UserTypeEntity record) {
        return typeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateTypeByPrimaryKey(UserTypeEntity record) {
        return typeMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<UserTypeEntity> seletListTypes(UsersTypeFilter filter) {



        UserTypeEntity filer = new UserTypeEntity();

        if (StringUtils.isNotBlank(filter.getUserType())) {
            filer.setUserType(filter.getUserType());
        }

        return typeMapper.selectListUserTypes(filer);
    }
}
